<?php

require_once 'php/conexion.php';

class listDisease {
    
    private $conx;
    private $table;
    private $dis = "SELECT * FROM DISEASE";
    private $disease = "SELECT * FROM disease  WHERE diseasecod = '%s'";    
    
    public function __construct() {
        $this->conx = null;
    }

    public function listdisease() {
        $consult = sprintf($this->dis);
        $this->conx = new conexion();
        $result = pg_exec($this->conx->getConexionDB(), $consult);
        $this->conx->closeConexionDB();
        $this->conx = null;
        if (!$result) {
            echo 'Error listando los Lotes \n';
        } while ($rows = pg_fetch_row($result)) {
            echo "<option value={$rows[0]}>{$rows[1]}</option>";
        }
        return $this->table;
    }
    
    public function listDis($id) {
        $this->table = "";
        $consult = sprintf($this->disease, $id);
        $this->conx = new conexion();
        $result = pg_exec($this->conx->getConexionDB(), $consult);
        $this->conx->closeConexionDB();
        $this->conx = null;
        $row = pg_num_rows($result);
        if ($row == 0) {
            $this->table .= "<td>No se Encuentran Ganados para este Lote</td>";
        } else {
            while ($rows = pg_fetch_array($result)) {
                $this->table .= "<tr>";
                $this->table .= "<td>{$rows['diseasename']}</td>";
                $this->table .= "<td>{$rows['symptom']}</td>";
                $this->table .= "<td>{$rows['tratamient']}</td>";
                $this->table .= "</tr>";
            }
        }
        return $this->table;
    }
    
    
}

?>
